/*
 * GatlingProjectile.java
 *
 * Created on 28. April 2007, 02:06
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package de.tor.obj.impl;

import com.golden.gamedev.object.SpriteGroup;
import com.golden.gamedev.object.sprite.VolatileSprite;
import de.tor.loaders.Level;
import de.tor.obj.*;
import java.awt.image.BufferedImage;

/**
 *
 * @author Charon
 */
public class GatlingShrapnellProjectile extends AbstractProjectile {
    
    private final static String RESOURCE =  "resources/gatling_shrapnell_shell.png";
    private final static String SYMBOL_RESOURCE =  "resources/gatling_shrapnell_symbol.png";
    private SpriteGroup mShrapnells = null;
    private int iHealth = 10;
    
    /** Creates a new instance of GatlingProjectile */
    public GatlingShrapnellProjectile(TorridityGameObject pOwner, Level pLevel, BufferedImage image) {
        super(pOwner, pLevel, image);
    }
    
    public static int getShotsPerSecond(){
        return 5;
    }
    
    public static String getResourceName(){
        return RESOURCE;
    }
    
    public static String getSymbolResourceName(){
        return SYMBOL_RESOURCE;
    }
    
    public int getCollisionDamage(){
        return 10;
    }
    
    public void setupProjectile() {
        setVerticalSpeed(-0.5);
    }
    
    public void doDamage(int v){
        iHealth -= v;
    }
    
    public int getMaxHealth() {
        return 10;
    }
    
    public int getHealth(){
        return iHealth;
    }
    
    public VolatileSprite getDestructionAnimation() {
        mShrapnells = new SpriteGroup("Shrapnells");
        
        for(int i=0;i<8;i++){
            AbstractProjectile s1 = ProjectileFactory.factorProjectile(getOwner(), ProjectileFactory.GATLING_SHRAPNELL);
            s1.setupProjectile();
            switch(i){
                case 0:{
                    s1.setHorizontalSpeed(1);
                    s1.setVerticalSpeed(0);
                    break;
                }case 1:{
                    s1.setHorizontalSpeed(0);
                    s1.setVerticalSpeed(1);
                    break;
                }case 2:{
                    s1.setHorizontalSpeed(-1);
                    s1.setVerticalSpeed(0);
                    break;
                }case 3:{
                    s1.setHorizontalSpeed(0);
                    s1.setVerticalSpeed(-1);
                    break;
                }case 4:{
                    s1.setHorizontalSpeed(1);
                    s1.setVerticalSpeed(1);
                    break;
                }case 5:{
                    s1.setHorizontalSpeed(-1);
                    s1.setVerticalSpeed(1);
                    break;
                }case 6:{
                    s1.setHorizontalSpeed(1);
                    s1.setVerticalSpeed(-1);
                    break;
                }default:{
                    s1.setHorizontalSpeed(-1);
                    s1.setVerticalSpeed(-1);
                    break;
                }
            }
            s1.setLocation(getX(), getY());
            mShrapnells.add(s1);
        }
        getLevel().fireProjectileProjectileEvent(mShrapnells);
        return null;
    }
    
    public void initObject() {
    }
    
    public boolean isDestructable() {
        return true;
    }
    
    public void updateTorridityGameObject(long elapsedTime) {
        addVerticalSpeed(elapsedTime, 0.25, -1);
    }
}
